﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core.Base;
using ERP.BusinessEntities;
using System.Windows.Forms;
using System.IO;
using Core;
using System.Data;

namespace MainApp.Modules.Stock
{
    public class StockModule: BaseModule
    {
        public StockModule()
        {
            this.Name = "Stock";
            entity = new StockEntity();
            Init();
        }

        public override void Import()
        {
            //OpenFileDialog openFileDlg = new OpenFileDialog();
            //openFileDlg.Multiselect = false;
            //openFileDlg.ShowDialog();

            //String strFileName = openFileDlg.FileName;

            //if (File.Exists(strFileName) == false) return;

            //ExcelClient exClient = new ExcelClient(strFileName);
            //exClient.OpenConnection();
            //String[] lstSheets = exClient.GetSheetName();
            //DataTable dt = exClient.GetAllDataFromSheet(lstSheets[0]);
            //foreach (DataRow dr in dt.Rows)
            //{
            //    try
            //    {
            //        ICStocksInfo Stock = new ICStocksInfo();
            //        Stock.No = Convert.ToString(dr[0]);
            //        Stock.Name = Convert.ToString(dr[1]);
            //        if(dr[3] != null && dr[3] != DBNull.Value)
            //            Stock.SaleUnitPrice = Convert.ToDouble(dr[3]);
            //        if (dr[4] != null && dr[4] != DBNull.Value)
            //            Stock.PurchaseUnitPrice = Convert.ToDouble(dr[4]);
            //        Stock.Desc = Stock.Name;
            //        Stock.FK_ICStockUOMs_ID = 1;
            //        Stock.FK_ICStocks_ID = 1;
            //        Stock.FK_ICStockCats_ID = 7;
            //        Stock.FK_TxTaxCodes_OutVATID = 1;
            //        Stock.FK_TxTaxCodes_InVATID = 6;
            //        Stock.MinQty = 6;
            //        Stock.isStockItem = true;
            //        Stock.CreatedDate = DateTime.Now;
            //        Stock.UpdatedDate = DateTime.Now;
            //        AppContext.StockCtrl.CreateObject(Stock);
            //    }
            //    catch (Exception)
            //    {
                    
            //    }
                
            //}

        }

    }
}
